Conditions | 3 |
Total Lines | 29 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { EventType } from './Event.entity'; |
||
6 | public index(items: ICalendar[]): ICalendarOverview { |
||
7 | const itemsByDate = []; |
||
8 | const overview: ICalendarOverview = { |
||
9 | mission: 0, |
||
10 | dojo: 0, |
||
11 | formationConference: 0, |
||
12 | leave: 0, |
||
13 | support: 0, |
||
14 | other: 0, |
||
15 | mealTicket: 0 |
||
16 | }; |
||
17 | |||
18 | for (const item of items) { |
||
19 | const dayIndex = new Date(item.getDate()).getDate() - 1; |
||
20 | const time = item.getTime() / 100; |
||
21 | const type = item.getType(); |
||
22 | |||
23 | if (itemsByDate[dayIndex]) { |
||
24 | itemsByDate[dayIndex].push({time, type}); |
||
25 | } else { |
||
26 | itemsByDate[dayIndex] = [{time, type}]; |
||
27 | } |
||
28 | |||
29 | overview[item.getType()] += time; |
||
30 | } |
||
31 | |||
32 | return { |
||
33 | ...overview, |
||
34 | mealTicket: this.getNumberOfMealTickets(Object.values(itemsByDate)) |
||
35 | }; |
||
58 |